home *** CD-ROM | disk | FTP | other *** search
- Path: badger.wmin.ac.uk!kruppd
- From: kruppd@westminster.ac.uk (Declan Kruppa)
- Newsgroups: comp.lang.c
- Subject: ? pointer to array of pointers
- Date: 22 Jan 1996 16:05:33 GMT
- Organization: University of Westminster
- Message-ID: <4e0ckd$ht1@badger.wmin.ac.uk>
- NNTP-Posting-Host: badger.wmin.ac.uk
- X-Newsreader: TIN [version 1.2 PL2]
-
- I am trying to use some routines in "Numerical Recipies in C"
- The book gives code for a function char **matrix which allocates
- memory for a
- a pointer to an array of ponters. If I call this function with
- a=matrix(1,10,1,10) it seems to work ok and I can access the elements of
- the array using a[i][j] .
- However I would like to be able to step through the array using pointer
- notation such as *p++ or **p++ . What would be the notation to step through the 10000 elements sequentily using pointer notation.
-
- Also I would like to write the pointer to a file stream like:
- File *fp
- fp=fopen("FILE","wb");
- fwrite(a,1,10000,fp);
-
- but when I read back the file it is not at all what I expect.
- I think that *p is a ponter to the rows in the matrix so I would expect it to
- step through every 10th element in the array. I don't know how to access
- sequential elements a[1][1], a[1][2] etc using pointer arithmetic or how to
- write it to a file.
- Any help appreciated.
-
- Declan Kruppa
- University of Westminster
-